package tw.qlife.atobe;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JPanel;

/**
 * Sliding a picture in its client area.
 * 
 * @author sytseng
 * 
 */
public class PicturePanel extends JPanel {

	private BufferedImage m_Img = null;
	
	public PicturePanel( ) {
		
		try {
		
			m_Img = ImageIO.read(new File("d:\\Mafia.jpeg"));
		}catch (IOException e ) { e.printStackTrace(); }
		
	}

	@Override
	public Dimension getMaximumSize() {
		return new Dimension(m_Img.getWidth(), m_Img.getHeight());
	}

	@Override
	public Dimension getMinimumSize() {
		return getPreferredSize();
	}

	@Override
	public Dimension getPreferredSize() {
		return new Dimension(m_Img.getWidth(), m_Img.getHeight());
	}

	@Override
	public void paintComponent(Graphics g) {
		
		super.paintComponent(g);
		//Graphics2D g2 = (Graphics2D) g;
		
		g.drawImage(m_Img, 0, 0,  null);
		
	}

}
